Lesson: 13 - LOOP (Repeat and Repeat Until)

Purpose :Students learn the concept of looping through repeat and repeat until.

Materials Required

Scratch 3.0, and Blockly game.

Curriculum Content 5.4) Loops, 6.12) Variables
Prior knowledge

Knowledge of directions and counting. Completed unplugged activities in lesson 10 and have an idea of looping.

Exercises

Exercise:1



  1. Write a code in which the sprite will ask the user to enter a number. The program will then check if the number is a prime number or not and display the result.


See the video for your reference.

Exercise:2



  1. Write a scratch code in which the computer selects a random number between some boundaries in its memory and the user has to find the number. Here you have only 5 chances to guess the number. The program will stop if the correct answer is guessed or if the number of guesses is exceeded. Another variant of this is, when you make a guess the computer will tell you whether the answer is above your guess or below your guess.


See the video for your reference.

Exercise:3



  1. Use the repeat until block to make the first exercise without any limitation.

See the video for your reference.

Solutions



  • Click here to view the sb3 file to complete exercise-1. (Solution).
  • Click here to view the sb3 file to complete exercise-2. (Solution).
  • Click here to view the sb3 file to complete exercise-3. (Solution).

  • Teacher's Instruction
    1. Emphasise that the students are learning loops.
    2. Students should play the Dice game in Lesson 10 before trying the exercises.
    3. Teachers should use technical programming words like conditions, loop, code, variable etc.
    4. In the variant where the computer tells whether the correct answer is above or below the guess, ask the students to think about how they can guess with the smallest number of guesses if the number is between 1 and 100. Introduce them to the idea of Binary search. For older children you can also ask them to think about how many guesses it will take to find a number between 1 and N. 2^(no of steps) > N. i.e. Log(N) steps.